package com.yejiali.backend.handler;

import com.yejiali.backend.utils.WebUtil;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @Author:yejiali
 * @Date:2025/5/11-05-11-15:44
 * @Decsription:com.yejiali.backend.handler
 * @Version:1.0
 */
//认证失败
@Component
public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {

        System.out.println("认证失败"+authException);
        WebUtil.renderString(response,"认证失败");
    }
}
